#include <cstdio>
#include <map>
#include <vector>
constexpr int MaxN = 2e2 + 5;
constexpr long long Mod = 1e9 + 7;
int n, k;
int in[MaxN];
bool sta[MaxN];
std::vector<int> g[MaxN];
std::map<int, int> map;
long long fsp(long long x, long long y)
{
    long long res = 1;
    for (; y != 0;)
    {
        if (y & 1)
        {
            res = res * x % Mod;
        }
        y >>= 1;
        x = x * x % Mod;
    }
    return res;
}
bool dfs(int u, int f, int meet, int cnt)
{
    meet += sta[u] ? 1 : 0;
    if (cnt == k)
    {
        if (meet == 1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    bool success = true;
    for (const auto &v : g[u])
    {
        if (v == f)
        {
            continue;
        }
        success &= dfs(v, u, meet, cnt + 1);
    }
    return success;
}
int main()
{
    freopen("life.in", "r", stdin);
    freopen("life.out", "w", stdout);
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n - 1; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
        in[u]++;
        in[v]++;
    }
    for (int i = 1; i <= n; i++)
    {
        map[in[i]]++;
    }
    if (map[1] == 2 && map[2] == n - 2)
    {
        printf("YES\n");
        printf("%d\n", k);
        return 0;
    }
    int answer = 0;
    for (int j = 0; j < 1 << n; j++)
    {
        for (int i = 1; i <= n; i++)
        {
            sta[i] = (j >> (i - 1)) & 1;
        }
        bool success = true;
        for (int i = 1; i <= n; i++)
        {
            success &= dfs(i, 0, 0, 1);
        }
        if (success)
        {
            answer++;
        }
    }
    printf("%s\n", answer != 0 ? "YES" : "NO");
    printf("%d\n", answer);
    return 0;
}
